<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="/assets/css/iconfont.css">
  <link rel="stylesheet" href="/assets/libs/bootstrap.min.css">
  <link rel="stylesheet" href="/assets/css/base.css">
  <link rel="stylesheet" href="/assets/css/admin.css">
  <link rel="stylesheet" href="/assets/css/ad-public.css">
</head>


<body>
  <!-- 侧边栏 -->
  @@include('../assets/common/admin/adminNav.html')

  <!-- 主体 -->
  <div class="main">
    <!-- 头部 -->
    @@include('../assets/common/admin/adminMainHeader.html')
    <!-- 内容区 -->
    <div class="content">
      <div class="content-item text-center">
        <h1>One Belt, One Road</h1>
        <p>Thoughts, stories and ideas.</p>
        <p>
          <a href="post-add.html" class="btn btn-primary btn-lg">
            写文章
          </a>
        </p>
      </div>
      <div class="row">
        <div class="col-md-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">站点内容统计：</h3>
            </div>
            <ul class="list-group">
              <li class="list-group-item"><strong class="posts"></strong>篇文章（<strong class="draft"></strong>篇草稿）</li>
              <li class="list-group-item"><strong class="cate"></strong>个分类</li>
              <li class="list-group-item"><strong class="comm"></strong>条评论 （<strong>0</strong>条评论）</li>
            </ul>
          </div>
        </div>
        <div class="col-md-4"></div>
        <div class="col-md-4"></div>
      </div>
    </div>
  </div>

  @@include('../assets/common/adminBase.html')

  <script>
    // main 数据渲染
    // 登录状态下 才可以渲染数据
    $(function () {
      // 获取文章数量
      $.ajax({
        url: baseUrl + '/posts/count',
        type: 'get',
        success(res) {
          if (res && isLogin) {
            $('.posts').html(res.postCount)
            $('.draft').html(res.draftCount)
          }
        }
      })
      // 获取分类
      $.ajax({
        url: baseUrl + '/categories/count',
        success(res) {
          if (res && isLogin) {
            $('.cate').html(res.categoryCount)
          }
        },
        error(err) {
          console.log(err);
        }
      })

      // 获取评价信息
      $.ajax({
        url: baseUrl + '/comments/count',
        success(res) {
          if (res && isLogin) {
            $('.comm').html(res.commentCount)
          }
        },
        error(err) {
          console.log(err);
        }
      })

    })
  </script>

</body>

</html>